package com.gx.smart.construction.ui.home.activity;

import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.navigation.Navigation;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.gx.smart.base.BaseMVVMActivity;
import com.gx.smart.construction.R;
import com.gx.smart.construction.databinding.ActivityMainBinding;
import com.gx.smart.construction.ui.home.viewmodel.MainViewModel;

import dagger.hilt.android.AndroidEntryPoint;

@AndroidEntryPoint
public class MainActivity extends BaseMVVMActivity<ActivityMainBinding, MainViewModel> {


    @Override
    protected Class<MainViewModel> onBindViewModel() {
        return MainViewModel.class;
    }

    @Override
    protected ActivityMainBinding onBindViewBinding(@NonNull LayoutInflater inflater) {
        return DataBindingUtil.setContentView(this, R.layout.activity_main);
    }



    @Override
    protected void initView() {
        binding.bottomNavigationBar.addItem(
                new BottomNavigationItem(R.mipmap.ic_home_selected, "首页")
                        .setInactiveIconResource(R.mipmap.ic_home))
                .addItem(new BottomNavigationItem(R.mipmap.ic_mine_selected, "我的")
                        .setInactiveIconResource(R.mipmap.ic_mine))
                .setMode(BottomNavigationBar.MODE_FIXED)
                .setActiveColor(R.color.font_color_style_19)
                .setInActiveColor(R.color.font_color_style_five)
                .setFirstSelectedPosition(0)
                .initialise();
        binding.bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
            @Override
            public void onTabSelected(int position) {//未选中 -> 选中
                switch (position) {
                    case 0:
                        Navigation.findNavController(
                                MainActivity.this,
                                R.id.navHostFragmentEnter
                        ).navigate(R.id.action_global_homeFragment);
                        break;
                    case 1:
                        Navigation.findNavController(
                                MainActivity.this,
                                R.id.navHostFragmentEnter
                        ).navigate(R.id.action_global_mineFragment);
                        break;
                }
            }

            @Override
            public void onTabUnselected(int position) {//选中 -> 未选中
            }

            @Override
            public void onTabReselected(int position) {//选中 -> 选中
            }
        });
    }

}